import request from '@utils/request'
import { saveAs } from 'file-saver'

// 新增文件夹
export function newFolder(tree) {
  return request({
      url: '/business/folder',
      headers: {
          isToken: false
      },
      method: 'post',
      data: tree
  })
}

// 修改文件夹
export function changeFolder(data) {
  return request({
      url: '/business/folder',
      headers: {
          isToken: false
      },
      method: 'put',
      data: data
  })
}

// 批量修改状态
export function changeFolderStatus(folderId) {
  return request({
      url: `/business/folder/editStatus?folderId=${folderId}`,
      headers: {
          isToken: false
      },
      method: 'get',
  })
}

// 删除文件夹
export function delFolder(folderIds) {
  return request({
      url: `/business/folder/${folderIds}`,
      headers: {
          isToken: false
      },
      method: 'DELETE',
  })
}

// 查询文件夹列表
export function searchFolderList(type,userId) {
  return request({
      url: '/business/folder/list?type=' + type + '&userId=' + userId,
      headers: {
          isToken: false
      },
      method: 'get',
  })
}
// 修改文件夹排序
export function changeFolderSort(data) {
  return request({
      url: '/business/folder/editSort',
      headers: {
          isToken: false
      },
      method: 'put',
      data: data
  })
}

// 查询空间要素信息列表
export function searchElementList(folderId) {
  return request({
      url: '/business/element/list?folderId=' + folderId,
      headers: {
          isToken: false
      },
      method: 'get',
  })
}

// 修改空间要素排序
export function changeElementSort(data) {
  return request({
      url: '/business/element/editSort',
      headers: {
          isToken: false
      },
      method: 'put',
      data: data
  })
}

// 修改空间要素
export function changeElement(data) {
  return request({
      url: '/business/element',
      headers: {
          isToken: false
      },
      method: 'put',
      data: {
        ...data,
        isDelOss:1
      }
  })
}

// 删除空间要素
export function delElement(folderIds) {
  return request({
      url: `/business/element/${folderIds}`,
      headers: {
          isToken: false
      },
      method: 'DELETE',
  })
}

// 新增空间要素
export function newGeom(data) {
  return request({
      url: '/business/element',
      headers: {
          isToken: false
      },
      method: 'post',
      data: data
  })
}

// 要素统计
export function getElementStat(type, isOpen) {
  return request({
      url: `/business/element/statistic/${type}/${isOpen}`,
      headers: {
          isToken: false
      },
      method: 'get',
  })
}
